﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>get static & nostatic value from class current</title>
<meta name="GENERATOR" content="WinCHM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>

<body><FONT >
<P align=left><FONT face=Courier><FONT 
color=#ff0000 size=5><STRONG>Trả về giá trị của một biến static từ một object : 
</STRONG></FONT> 
           <BR>JNIEXPORT 
jint</FONT><FONT face=Courier> JNICALL 
<B>Java_<FONT 
color=#ff00ff>yourpackage</FONT>_<FONT 
color=#ff0000>YourClassName</FONT>_<FONT 
color=#0000ff>getStaticValueDemo</FONT></B>  
(JNIEnv * env,jobject obj) {</FONT></P>
<P align=left><FONT face=Courier>&nbsp;&nbsp;&nbsp;&nbsp; jclass cls = 
 (*env)-&gt;GetObjectClass(env, obj);   </P>
<P align=left><FONT face=Courier>&nbsp;&nbsp;&nbsp;&nbsp; jfieldID fid = 
(*env)-&gt;GetStaticFieldID(env, cls, </FONT></FONT><FONT face=Courier><FONT 
color=#2a00ff >"YourStaticAvaiable"</FONT><FONT >, </FONT><FONT color=#2a00ff 
>"I"</FONT></FONT><FONT ><FONT face=Courier>);</FONT></P>
<P align=left><FONT face=Courier>&nbsp;&nbsp;&nbsp;&nbsp; jint GiaTri = 
 (*env)-&gt;GetStaticIntField(env, cls, fid);    </P>
<P align=left></FONT><B><FONT color=#7f0055 ><FONT 
face=Courier>&nbsp;&nbsp;&nbsp;&nbsp; return</FONT></B></FONT><FONT 
><FONT 
face=Courier> GiaTri;</FONT> 
</P>
<P align=left><FONT 
face=Courier>}</FONT></P></FONT></FONT></FONT></body>
</html>
